<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <script>
        //累乘
        var mult = (function () {
            var arr = [];
            return function (n) {
                if (arr[n]) return arr[n];
                if (n === 1) return 1;
                return arr[n] = n * arguments.callee(n - 1);
            };
        })();
        //累加
        var sum = (function(){
            var arr = [];
            return function(n){
                if(arr[n]) return arr[n];
                if(n ===1) return 1;
                return arr[n] = n + arguments.callee(n -1);
            };
        })();
        //斐波那契
        var feib = (function(n){
            var arr = [];
            return function(n){
                if(arr[n])return arr[n];
                if(n === 2 || n === 1)return 1;
                return arr[n] = arguments.callee(n - 1) + arguments.callee(n - 2);
            }
        })();
    </script>
</body>

</html>